<template>
  <div>
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>巡检系统</el-breadcrumb-item>
        <el-breadcrumb-item>巡检计划</el-breadcrumb-item>
      </el-breadcrumb>
      <el-form :inline="true" :model="patrolPlan" class="demo-form-inline">
        <el-row>
            <el-col :span="5">
                <el-form-item label="巡检编号">
                    <el-input v-model="patrolPlan.planNo" placeholder="请输入编号"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                <el-form-item label="计划名称">
                    <el-input v-model="patrolPlan.planName" placeholder="请输入计划名称"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                <el-form-item label="巡检类型">
                    <el-select v-model="patrolPlan.patType" placeholder="请选择">
                        <el-option :label="p.patType" v-for="p in patrolType" :key="p.id" :value="p.sys"></el-option>
                    </el-select>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                <el-form-item label="巡检周期">
                    <el-select v-model="patrolPlan.patCycle" placeholder="请选择">
                    <el-option :label="c.patCyle" v-for="c in patrolCycle" :key="c.id" :value="c.sys"></el-option>
                    </el-select>
                </el-form-item>
            </el-col>
        </el-row>

        <el-row>
            <el-col :span="5">
                <el-form-item label="开始日期">
                    <el-date-picker
                        v-model="patrolPlan.startDate"
                        type="date"
                        placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                <el-form-item label="结束日期">
                    <el-date-picker
                        v-model="patrolPlan.endDate"
                        value-format="yyyy-MM-dd"
                        type="date"
                        placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="5">
                 <el-form-item>
                    <el-button type="info" @click="onSubmit">查询</el-button>
                    <el-button @click="clear">清空</el-button>
                </el-form-item>
            </el-col>
        </el-row>
      </el-form>
      <el-button type="success" @click="addPlan" class="btn1" plain>添加</el-button>
        <div class="bbb">
        <el-table class="tab1"
            :data="tableData"
            stripe
            style="width: 100%">
            <el-table-column type="index" :index="index" label="序号" width=""></el-table-column>
            <el-table-column prop="planNo" label="计划编号" width=""></el-table-column>
            <el-table-column prop="planName" label="计划名称" width=""></el-table-column> 
            <el-table-column prop="patType" label="巡检类型" width="">
                <template slot-scope="scope">
                    <span>{{scope.row.patType==0?'常规巡检':'紧急巡检'}}</span>
                </template>
            </el-table-column>
            <el-table-column prop="patCycle" label="巡检周期" width="">
                <template slot-scope="scope">
                    <span>{{scope.row.patCycle==0?'天':scope.row.patCycle==1?'周':scope.row.patCycle==2?'月':scope.row.patCycle==3?'季度':scope.row.patCycle==4?'半年':'年'}}</span>
                </template>
            </el-table-column>
            <el-table-column prop="startDate" label="开始日期" width=""></el-table-column>
            <el-table-column prop="endDate" label="结束日期" width=""></el-table-column>
            <el-table-column prop="planNum" label="巡检点数量" width=""></el-table-column>
            <el-table-column label="操作" width="350">
                <template slot-scope="scope">
                    <el-button size="mini" @click="seePlan(scope.row)" round>查看</el-button>
                    <el-button size="mini" @click="updatePatrolPlan(scope.row)" round>修改</el-button>
                    <el-button type="danger" size="mini" @click="delPlan(scope.row.id)" round>删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        </div>
        <el-pagination class="pag"
            layout="prev, pager, next"
            :total="totle"
            :page-size='pageSize'
            @current-change='change'>
        </el-pagination>

        <!-- 添加框 -->
        <el-dialog title="添加巡检计划" :visible.sync="addVisible">
            <el-form  :rules="rules"  ref="ruleForm" :model="addPlanm">
            <el-row>
                <el-col :span="10">
                <el-form-item label="巡检编号" label-width="80px" prop="planNo">
                    <el-input v-model="addPlanm.planNo" placeholder="请输入编号"></el-input>
                </el-form-item>
            </el-col>
            
            <el-col :span="10" push="1">
                <el-form-item label="计划名称" label-width="80px" prop="planName">
                    <el-input v-model="addPlanm.planName" placeholder="请输入计划名称"></el-input>
                </el-form-item>
            </el-col>
            </el-row>

            <el-row>
                <el-col :span="10">
                <el-form-item label="巡检类型" label-width="80px" prop="patType">
                    <el-select v-model="addPlanm.patType" placeholder="请选择">
                        <el-option :label="p.patType" v-for="p in patrolType" :key="p.id" :value="p.sys"></el-option>
                    </el-select>
                </el-form-item>
            </el-col>
            
            <el-col :span="10" push="1">
                <el-form-item label="巡检周期" label-width="80px" prop="patCycle">
                    <el-select v-model="addPlanm.patCycle" placeholder="请选择">
                    <el-option :label="c.patCyle" v-for="c in patrolCycle" :key="c.id" :value="c.sys"></el-option>
                    </el-select>
                </el-form-item>
            </el-col>
            </el-row>

             <el-row>
                <el-col :span="10">
                <el-form-item label="开始日期" label-width="80px" prop="startDate">
                    <el-date-picker
                        v-model="addPlanm.startDate"
                        type="date"
                        placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>
            </el-col>
            
            <el-col :span="10" push="1">
               <el-form-item label="结束日期" label-width="80px" prop="endDate">
                    <el-date-picker
                        v-model="addPlanm.endDate"
                        type="date"
                        placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>
            </el-col>
            </el-row>


            <el-row>
                <el-col :span="21">
                    <el-form-item label="备注" label-width="80px">
                        <el-input type="textarea" v-model="addPlanm.remark" placeholder="请输入备注"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="21">
                    <h4>请选择添加巡检点:</h4>
                </el-col>
            </el-row>


             <el-row>
                <el-col :span="21">
                    <el-table ref="multipleTable1" :data="pointData" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange">
                        <el-table-column type="selection" width="60"></el-table-column>
                        <el-table-column prop="pointNo" label="巡检点编号" width="200"></el-table-column>
                        <el-table-column prop="pointName" label="巡检点名称" width="200"></el-table-column>
                        <el-table-column prop="address" label="巡检点地址" width="200"></el-table-column>
                    </el-table>
                </el-col>
            </el-row>

                
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="addVisible = false">取 消</el-button>
                <el-button type="primary" @click="addPatrolPoint('ruleForm')">添 加</el-button>
            </div>
        </el-dialog>

        <!-- 查看详情框 -->
        <el-dialog title="详情" width="70%" :visible.sync="seeVisible">
            <el-form>
            <el-row class="row1">
                <el-col :span="21">
                    <span class="span1">巡检计划信息:</span>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="7">
                <el-form-item label="巡检编号:" label-width="80px">
                    <span v-text="seeData.planNo"></span>
                </el-form-item>
            </el-col>
            
            <el-col :span="7" push="1">
                <el-form-item label="计划名称:" label-width="80px">
                    <span v-text="seeData.planName"></span>
                </el-form-item>
            </el-col>

            <el-col :span="7" push="1">
                <el-form-item label="巡检类型:" label-width="80px">
                    <span>{{seeData.patType==0?'常规巡检':'紧急巡检'}}</span>
                </el-form-item>
            </el-col>
            </el-row>

            <el-row>
                <el-col :span="7">
                <el-form-item label="巡检周期:" label-width="80px">
                    <span>{{seeData.patCycle==0?'天':seeData.patCycle==1?'周':seeData.patCycle==2?'月':seeData.patCycle==3?'季度':seeData.patCycle==4?'半年':'年'}}</span>
                </el-form-item>
            </el-col>
            
            <el-col :span="7" push="1">
                <el-form-item label="开始日期:" label-width="80px">
                    <span v-text="seeData.startDate"></span>
                </el-form-item>
            </el-col>

            <el-col :span="7" push="1">
                <el-form-item label="结束日期:" label-width="80px">
                    <span v-text="seeData.endDate"></span>
                </el-form-item>
            </el-col>
            </el-row>


            <el-row>
                <el-col :span="21">
                    <el-form-item label="备注:" label-width="80px">
                        <span v-text="seeData.remark"></span>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row class="row1">
                <el-col :span="21">
                    <span class="span1">巡检点列表:</span>
                </el-col>
            </el-row>


             <el-row>
                <el-col :span="21">
                    <el-table :data="seePointData" tooltip-effect="dark" style="width: 100%">
                        <el-table-column prop="pointNo" label="巡检点编号" width="300"></el-table-column>
                        <el-table-column prop="pointName" label="巡检点名称" width="300"></el-table-column>
                        <el-table-column prop="address" label="巡检点地址" width="300"></el-table-column>
                    </el-table>
                </el-col>
            </el-row>
            <el-row class="row1">
                <el-col :span="21">
                    <span class="span1">巡检任务列表: </span><el-button @click="addTask" type="success" plain>添加任务</el-button>
                </el-col>
            </el-row>


             <el-row>
                <el-col :span="24">
                    <el-table height="450" :data="seepatrolTaskList" tooltip-effect="dark" style="width: 100%">
                        <el-table-column prop="taskNo" label="任务号" width="200"></el-table-column>
                        <el-table-column prop="taskName" label="任务名" width="100"></el-table-column>
                        <el-table-column label="类型" width="80">
                            <template slot-scope="scope">{{scope.row.taskType=='plan'?'计划任务':'临时任务'}}</template>
                        </el-table-column>
                        <el-table-column label="状态" width="80">
                            <template slot-scope="scope">
                                {{scope.row.taskStatu==0?'新任务':scope.row.taskStatu==1?'新任务':scope.row.taskStatu==2?'执行中':scope.row.taskStatu==3?'等待审核':scope.row.taskStatu==4?'已完成':'审核不通过'}}
                            </template>
                        </el-table-column>
                        <el-table-column prop="executor" label="执行者" width="100"></el-table-column>
                        <el-table-column prop="dispatcher" label="创建者" width="100"></el-table-column>
                        <el-table-column prop="startDate" label="开始时间" width="200"></el-table-column>
                        <el-table-column prop="endDate" label="结束时间" width="200"></el-table-column>
                    </el-table>
                </el-col>
            </el-row>

                
            </el-form>
            <div slot="footer" style="text-align:center;" class="dialog-footer">
                <el-button type="primary" style="width:30%" @click="seeVisible=false">确 定</el-button>
            </div>
        </el-dialog>


        <!-- 修改框 -->
        <el-dialog title="修改巡检计划"  width="70%"  :visible.sync="updateVisible">
            <el-form :rules="rules" ref="rulesupdate" :model="updateSeeData">
            <el-row>
                <el-col :span="10">
                <el-form-item label="巡检编号" label-width="80px" prop="planNo">
                    <el-input v-model="updateSeeData.planNo" placeholder="请输入编号"></el-input>
                </el-form-item>
            </el-col>
            
            <el-col :span="10" push="1">
                <el-form-item label="计划名称" label-width="80px" prop="planName">
                    <el-input v-model="updateSeeData.planName" placeholder="请输入计划名称"></el-input>
                </el-form-item>
            </el-col>
            </el-row>

            <el-row>
                <el-col :span="10">
                <el-form-item label="巡检类型" label-width="80px" prop="patType">
                    <el-select v-model="updateSeeData.patType" placeholder="请选择">
                        <el-option :label="p.patType" v-for="p in patrolType" :key="p.id" :value="p.sys"></el-option>
                    </el-select>
                </el-form-item>
            </el-col>
            
            <el-col :span="10" push="1">
                <el-form-item label="巡检周期" label-width="80px" prop="patCycle">
                    <el-select v-model="updateSeeData.patCycle" placeholder="请选择">
                    <el-option :label="c.patCyle" v-for="c in patrolCycle" :key="c.id" :value="c.sys"></el-option>
                    </el-select>
                </el-form-item>
            </el-col>
            </el-row>

             <el-row>
                <el-col :span="10">
                <el-form-item label="开始日期" label-width="80px" prop="startDate">
                    <el-date-picker
                        v-model="updateSeeData.startDate"
                        type="date"
                        placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>
            </el-col>
            
            <el-col :span="10" push="1">
               <el-form-item label="结束日期" label-width="80px" prop="endDate">
                    <el-date-picker
                        v-model="updateSeeData.endDate"
                        type="date"
                        placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>
            </el-col>
            </el-row>


            <el-row>
                <el-col :span="21">
                    <el-form-item label="备注" label-width="80px">
                        <el-input type="textarea" v-model="updateSeeData.remark" placeholder="请输入备注"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="21">
                    <h4>请修改巡检点:</h4>
                </el-col>
            </el-row>


             <el-row>
                <el-col :span="21">
                    <el-table ref="multipleTable" :row-key="getRowKey" :data="pointData" tooltip-effect="dark" style="width: 100%" @selection-change="updatehandleSelectionChange">
                        <el-table-column type="selection" width="60"></el-table-column>
                        <el-table-column prop="pointNo" label="巡检点编号" width="200"></el-table-column>
                        <el-table-column prop="pointName" label="巡检点名称" width="200"></el-table-column>
                        <el-table-column prop="address" label="巡检点地址" width="200"></el-table-column>
                    </el-table>
                </el-col>
            </el-row>

            <el-row class="row1">
                <el-col :span="21">
                    <span class="span1">巡检任务列表: </span>
                </el-col>
            </el-row>


             <el-row>
                <el-col :span="24">
                    <el-table height="450" :data="updateSeepatrolTaskList" tooltip-effect="dark" style="width: 100%">
                        <el-table-column prop="taskNo" label="任务号" width="200"></el-table-column>
                        <el-table-column prop="taskName" label="任务名" width="170"></el-table-column>
                        <el-table-column label="类型" width="100">
                            <template slot-scope="scope">{{scope.row.taskType=='plan'?'计划任务':'临时任务'}}</template>
                        </el-table-column>
                        <el-table-column label="状态" width="100">
                            <template slot-scope="scope">
                                {{scope.row.taskStatu==0?'新任务':scope.row.taskStatu==1?'新任务':scope.row.taskStatu==2?'执行中':scope.row.taskStatu==3?'等待审核':scope.row.taskStatu==4?'已完成':'审核不通过'}}
                            </template>
                        </el-table-column>
                        <el-table-column prop="executor" label="执行者" width="120"></el-table-column>
                        <el-table-column prop="dispatcher" label="创建者" width="120"></el-table-column>
                        <el-table-column label="操作" width="300">
                            <template slot-scope="scope">
                                <el-button size="mini" @click="seeTask(scope.row)" round>查看</el-button>
                                <el-button size="mini" @click="updateTask(scope.row)" round>修改</el-button>
                                <el-button type="danger" size="mini" @click="delTask(scope.row.id)" round>删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-col>
            </el-row>
                
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="updateVisible = false">取 消</el-button>
                <el-button type="primary" @click="updatePointAndPlan('rulesupdate')">修 改</el-button>
            </div>
        </el-dialog>










        <!-- 添加任务弹框 -->
        <el-dialog title="添加巡检任务" :visible.sync="addTaskVisible">
            <el-form :model="addTaskValue" ref="addTaskFrom" :rules="updateTaskRules">
            <el-row>
                <el-col :span="10">
                <el-form-item label="任务名" label-width="80px" prop="taskName">
                    <el-input v-model="addTaskValue.taskName" placeholder="请输入任务名"></el-input>
                </el-form-item>
            </el-col>
            
            <el-col :span="10" push="1">
                <el-form-item label="任务类型" label-width="80px" prop="taskType">
                    <el-select v-model="addTaskValue.taskType" placeholder="请选择">
                        <el-option label="计划任务" value="plan">计划任务</el-option>
                        <el-option label="临时任务" value="temp">临时任务</el-option>
                    </el-select>
                </el-form-item>
            </el-col>
            </el-row>
   
            
            


             <el-row>
                <el-col :span="10">
                <el-form-item label="开始日期" label-width="80px" prop="startDate">
                    <el-date-picker
                        v-model="addTaskValue.startDate"
                        type="date"
                        placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>
            </el-col>
            
            <el-col :span="10" push="1">
               <el-form-item label="结束日期" label-width="80px" prop="endDate">
                    <el-date-picker
                        v-model="addTaskValue.endDate"
                        type="date"
                        placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>
            </el-col>
            </el-row>

            <el-row>
                <el-col :span="21">
                    <el-form-item label="任务内容" label-width="80px">
                        <el-input type="textarea" v-model="addTaskValue.content" placeholder="请输入备注"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="10">
                <el-form-item label="负责人" label-width="80px" prop="executor">
                    <el-select v-model="addTaskValue.executor" placeholder="请选择">
                        <el-option :label="user.userName" v-for="user in executors" :key="user.id" :value="user.userName"></el-option>
                    </el-select>
                </el-form-item>
            </el-col>
            </el-row>


            <el-row>
                <el-col :span="21">
                    <span>请选择巡检点：</span>
                </el-col>
                <el-col :span="21">
                    <el-table ref="multipleTable1" :data="addTaskPonit" tooltip-effect="dark" style="width: 100%" @selection-change="addTaskPonitSelectionChange">
                        <el-table-column type="selection" width="60"></el-table-column>
                        <el-table-column prop="pointNo" label="巡检点编号" width="200"></el-table-column>
                        <el-table-column prop="pointName" label="巡检点名称" width="200"></el-table-column>
                        <el-table-column prop="address" label="巡检点地址" width="200"></el-table-column>
                    </el-table>
                </el-col>
            </el-row>

                
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="addTaskVisible = false">取 消</el-button>
                <el-button type="primary" @click="addTaskvvv('addTaskFrom')">添 加</el-button>
            </div>
        </el-dialog>



        <!-- 查看任务框 -->
        <el-dialog title="详情" width="60%" :visible.sync="seeTaskVisible">
            <el-form>
            <el-row class="row1">
                <el-col :span="21">
                    <span class="span1">巡检任务信息:</span>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="7">
                <el-form-item label="任务编号:" label-width="80px">
                    <span v-text="seeTaskData.taskNo"></span>
                </el-form-item>
            </el-col>
            
            <el-col :span="7" push="1">
                <el-form-item label="任务名称:" label-width="80px">
                    <span v-text="seeTaskData.taskName"></span>
                </el-form-item>
            </el-col>

            <el-col :span="7" push="1">
                <el-form-item label="任务类型:" label-width="80px">
                    <span>{{seeTaskData.taskType=='plan'?'计划任务':'临时任务'}}</span>
                </el-form-item>
            </el-col>
            </el-row>

            <el-row>
                <el-col :span="7">
                <el-form-item label="任务状态:" label-width="80px">
                    <span>{{seeTaskData.taskStatu==0?'新任务':seeTaskData.taskStatu==1?'新任务':seeTaskData.taskStatu==2?'执行中':seeTaskData.taskStatu==3?'等待审核':seeTaskData.taskStatu==4?'已完成':'审核不通过'}}</span>
                </el-form-item>
            </el-col>
            
            <el-col :span="7" push="1">
                <el-form-item label="开始日期:" label-width="80px">
                    <span v-text="seeTaskData.startDate"></span>
                </el-form-item>
            </el-col>

            <el-col :span="7" push="1">
                <el-form-item label="结束日期:" label-width="80px">
                    <span v-text="seeTaskData.endDate"></span>
                </el-form-item>
            </el-col>
            </el-row>


            <el-row>

                <el-col :span="7">
                        <el-form-item label="执行人:" label-width="80px">
                            <span v-text="seeTaskData.executor"></span>
                        </el-form-item>
                </el-col>

                 <el-col :span="7" push="1">

                    <el-form-item label="发布人:" label-width="80px">
                        <span v-text="seeTaskData.dispatcher"></span>
                    </el-form-item>
                </el-col>
                <el-col :span="7" push="1">

                    <el-form-item label="描述:" label-width="80px">
                        <span v-text="seeTaskData.content"></span>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
               
                <el-col :span="21">

                    <el-form-item label="备注:" label-width="80px">
                        <span v-text="seeTaskData.remark"></span>
                    </el-form-item>
                </el-col>

            </el-row>

            <el-row class="row1">
                <el-col :span="21">
                    <span class="span1">巡检点列表:</span>
                </el-col>
            </el-row>


             <el-row>
                <el-col :span="23">
                    <el-table :data="taskPointData" tooltip-effect="dark" style="width: 100%">
                        <el-table-column prop="pointNo" label="巡检点编号" width="250"></el-table-column>
                        <el-table-column prop="pointName" label="巡检点名称" width="300"></el-table-column>
                        <el-table-column prop="address" label="巡检点地址" width="300"></el-table-column>
                    </el-table>
                </el-col>
            </el-row>

            
            </el-form>
            <div slot="footer" style="text-align:center;" class="dialog-footer">
                <el-button type="primary" style="width:30%" @click="seeTaskVisible=false">确 定</el-button>
            </div>
        </el-dialog>










        <!-- 修改框 -->
        <el-dialog title="修改巡检任务"  width="60%"  :visible.sync="updateTaskVisible">
            <el-form :model="updateTaskData" ref="validaterrrr" :rules="updateTaskRules">
            <el-row>
                <el-col :span="22">
                <el-form-item label="任务编号" label-width="80px" prop="taskNo">
                    <el-input v-model="updateTaskData.taskNo" placeholder="请输入编号"></el-input>
                </el-form-item>
            </el-col>
            </el-row>
            
            <el-row>
            <el-col :span="22">
                <el-form-item label="任务名称" label-width="80px" prop="taskName">
                    <el-input v-model="updateTaskData.taskName" placeholder="请输入计划名称"></el-input>
                </el-form-item>
            </el-col>
            </el-row>

            <el-row>
                <el-col :span="22">
                <el-form-item label="任务类型" label-width="80px" prop="taskType">
                    <el-select v-model="updateTaskData.taskType" placeholder="请选择">
                        <el-option label="计划任务" value="plan">计划任务</el-option>
                        <el-option label="临时任务" value="temp">临时任务</el-option>
                    </el-select>
                </el-form-item>
            </el-col>
            </el-row>
            
            <el-row>
            <el-col :span="22">
               <el-form-item label="结束日期" label-width="80px" prop="endDate">
                    <el-date-picker
                        v-model="updateTaskData.endDate"
                        type="date"
                        placeholder="选择日期">
                    </el-date-picker>
                </el-form-item>
            </el-col>
            </el-row>



            <el-row>
                <el-col :span="22">
                    <el-form-item label="备注" label-width="80px">
                        <el-input type="textarea" v-model="updateTaskData.remark" placeholder="请输入备注"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="21">
                    <span>请选择巡检点：</span>
                </el-col>
                <el-col :span="21">
                    <el-table ref="multipleTable33" :row-key="getRowKey" :data="updateTaskPonit" style="width: 100%" @selection-change="updateTaskPonitSelectionChange">
                        <el-table-column type="selection" width="60"></el-table-column>
                        <el-table-column prop="pointNo" label="巡检点编号" width="200"></el-table-column>
                        <el-table-column prop="pointName" label="巡检点名称" width="200"></el-table-column>
                        <el-table-column prop="address" label="巡检点地址" width="200"></el-table-column>
                    </el-table>
                </el-col>
            </el-row>
            
                
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="updateTaskVisible = false">取 消</el-button>
                <el-button type="primary" @click="updatedTask('validaterrrr')">修 改</el-button>
            </div>
        </el-dialog>


  </div>
</template>

<script>   
  export default{
      data(){
          
          return{
              patrolPlan:{
                  planNo:'',
                  planName:'',
                  patType:'',
                  patCycle:'',
                  startDate:'',
                  endDate:'',
              },
              tableData:[],
              totle:10,
              pageSize:5,
              pageIndex:1,

            //   巡检类型
            patrolType:[],
            // 巡检周期
            patrolCycle:[],

            // 添加框显示标志
            addVisible:false,
            // 查看框显示标志
            seeVisible:false,
            // 添加任务弹框显示标志
            addTaskVisible:false,
            // 修改框标志
            updateVisible:false,

            // 添加框数据
            addPlanm:{
                planNo:'',
                planName:'',
                patType:'',
                patCycle:'',
                startDate:'',
                endDate:'',
                remark:'',
                pointList:[]
            },
            updatePlanm:{
                planNo:'',
                planName:'',
                patType:'',
                patCycle:'',
                startDate:'',
                endDate:'',
                remark:'',
                pointList:[]
            },

            // 查看计划的数据
            seeData:{},
            // 修改计划的数据
            updateSeeData:{
                planNo:'',
                planName:'',
                patType:'',
                patCycle:'',
                startDate:'',
                endDate:'',
                remark:'',
                pointList:[],
            },
            // 添加巡检点列表数据
            pointData:[],
            // 修改巡检点列表数据
            updatePointData:[],

            // 查看巡检点列表数据
            seePointData:[],
            // 修改巡检点列表数据
            updateSeePointData:[],

            // 巡检任务列表数据
            seepatrolTaskList:[],
            // 修改巡检任务列表数据
            updateSeepatrolTaskList:[],

            // 选中的巡检点集合
            multipleSelection: [],
            // 修改后选中的巡检点集合
            updateMultipleSelection: [],
            // 回显的巡检点id
            arountPointId:[],





            // 添加任务巡检点集合
            addTaskPonit:[],

            // 修改后添加任务巡检点集合
            updateAddTaskPonit:[],


            // 查看任务巡检点集合
            taskPointData:[],


            // 修改任务巡检点集合
            updateTaskPonit:[],

            // 被选中的巡检点集合
            // checkedPonit:[],


            // 修改后任务巡检点集合
            updateTaskPonitAfter:[],

            // 最终传递 的修改后的巡检点id集合
            PonitAfters:[],


            






















            // 巡检计划的id
            seeplanId:'',

            // 添加计划任务的数据
            addTaskValue:{
                taskName:'',
                taskType:'',
                startDate:'',
                endDate:'',
                executor:'',
                content:'',
                planId:'',
                points:[],
            },

            // 可执行任务的人列表
            executors:[],

            













            // 修改计划中的任务
            // 当前任务数据
            seeTaskData:{},

            // 任务详情框标志
            seeTaskVisible:false,

            // 修改任务数据
            updateTaskData:{
                id:'',
                taskNo:'',
                taskName:'',
                taskType:'',
                taskStaru:'',
                startDate:'',
                endDate:'',
                remark:'',
                executor:'',
                dispatcher:'',
                content:'',
                points:[],
            },

            // 修改任务框标志
            updateTaskVisible:false,

            // 巡检点修改时 修改后的巡检点id集合
            updateArountPointId:[],




            // 修改计划后的巡检点集合id
            updatePlanTasked:[],

            




            











            // 添加表单验证
            rules:{
                planNo:[
                    {required: true, message: '请输入计划编号', trigger: 'blur'},
                    { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
                ],
                planName:[
                    {required: true, message: '请输入计划名', trigger: 'blur'},
                    { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
                ],
                patType:[
                    {required: true, message: '请选择计划类型', trigger: 'blur'},
                ],
                patCycle:[
                    {required: true, message: '请选择计划周期', trigger: 'blur'},
                ],
                startDate:[
                    {required: true, message: '请选择开始时间', trigger: 'blur'},
                ],
                endDate:[
                    {required: true, message: '请选择结束时间', trigger: 'blur'},
                ],

            },

            // 修改任务表单验证
            updateTaskRules:{
                taskNo:[
                    {required: true, message: '请输入任务编号', trigger: 'blur'},
                    { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
                ],
                taskName:[
                    {required: true, message: '请输入任务名', trigger: 'blur'},
                    { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
                ],
                taskType:[
                    {required: true, message: '请选择任务类型', trigger: 'blur'},
                ],
                startDate:[
                    {required: true, message: '请选择开始时间', trigger: 'blur'},
                ],
                endDate:[
                    {required: true, message: '请选择结束时间', trigger: 'blur'},
                ],
                executor:[
                    {required: true, message: '请选择结束时间', trigger: 'blur'},
                ],

            },






            //弹框表单项宽度
            formLabelWidth: '120px'
            
          }
      },
      methods:{
          clear(){
              this.patrolPlan.planNo=''
              this.patrolPlan.planName=''
              this.patrolPlan.patType=''
              this.patrolPlan.patCycle=''
              this.patrolPlan.startDate=''
              this.patrolPlan.endDate=''
          },
          change(e){
              console.log(e);
              this.pageIndex=e;
              this.getList();
          },
          getList(){
              this.axios.post("patrol/plan?pageSize="+this.pageSize+"&pageIndex="+this.pageIndex,this.patrolPlan).then(res=>{
                this.totle=res.data.data.total;
                this.tableData=res.data.data.list;
            })
          },
          onSubmit(){
              this.pageIndex=1;
              this.getList();
          },
          index(dex){
              return (this.pageIndex-1)*this.pageSize+dex+1;
          },
          getPatrolType(){
            this.axios.get("pattype/all").then(res=>{
                console.log(res.data.data);
                this.patrolType=res.data.data
            })
          },
          getPatrolCycle(){
            this.axios.get("patcycle/all").then(res=>{
                console.log(res.data.data);
                this.patrolCycle=res.data.data
            })
          },
        //   添加
            addPlan(){
                this.addPlanm.planNo=''
                this.addPlanm.planName=''
                this.addPlanm.patType=''
                this.addPlanm.patCycle=''
                this.addPlanm.starDate=''
                this.addPlanm.endDate=''
                this.addPlanm.remark=''
                this.pointList=[],

                // 
                


                
                this.addVisible=true;
                this.$refs.multipleTable1.clearSelection();
                
            },
            // 添加巡检点表单变化时调用
            handleSelectionChange(val) {
                this.multipleSelection = val;
            },

            // addTaskPonitSelectionChange添加任务巡检点集合改变时调用
            addTaskPonitSelectionChange(val){
                // 最终提交的任务巡检点
                this.updateAddTaskPonit=val;
                console.log(this.updateAddTaskPonit);
            },


            
            //修改任务巡检点集合改变时调用
            updateTaskPonitSelectionChange(val){
                console.log(val);
                this.PonitAfters=val;
            },






            // 查询出当前计划的巡检点集合
            findPointByPlanId(){
                this.axios.get("patrolpoint/findById?id="+ this.seeplanId).then(res=>{
                    console.log(res.data.data);
                    this.addTaskPonit=res.data.data;
                 })
            },



            // 执行添加
            addPatrolPoint(ruleForm){
                this.$refs[ruleForm].validate((valid) => {
                    if (valid) {
                        console.log(this.multipleSelection);
                        this.addPlanm.pointList=this.multipleSelection;
                        this.axios.post("patrolpoint/add",this.addPlanm).then(res=>{
                            console.log(res.data);
                            this.getList()
                            this.$message(res.data.msg);
                            this.addVisible=false;
                        })
                    } else {
                        return false;
                    }
                });

                
            },
            // 点击删除
            delPlan(id){
                this.$confirm('您确认删除?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
                }).then(() => {
                    this.axios.get("patrolpoint/del?id="+id).then(res=>{
                    this.getList()
                    this.$message(res.data.msg);
                 })
                })
            },

            // 点击查看按钮
            seePlan(row){
                this.seeplanId=row.id;
                this.axios.get("patrolpoint/findById?id="+row.id).then(res=>{
                    // console.log(res.data.data);
                    this.seePointData=res.data.data;
                 })
                this.findTask();
                console.log(row);
                this.seeVisible=true;
                this.seeData=row;
            },
            //查询任务
            findTask(){
                 this.axios.get("patrolTask/findById?id="+this.seeplanId).then(res=>{
                    console.log(res.data.data);
                    this.seepatrolTaskList=res.data.data;
                 })
            },
            
            // 添加任务
            addTask(){
                this.addTaskValue={};
                
                this.findPointByPlanId();
                this.addTaskVisible=true;
            },
            // 获取可执行任务的人的集合
            getExecutors(){
                this.axios.get("user/getExecutors").then(res=>{
                    this.executors=res.data.data
                    
                })
            },

            // 给计划添加任务
            addTaskvvv(addTaskFrom){

                this.$refs[addTaskFrom].validate((valid) => {
                    if (valid) {
                        this.addTaskValue.points=this.updateAddTaskPonit;
                        this.addTaskValue.planId=this.seeData.id;
                        this.axios.post("patrolTask/addtask",this.addTaskValue).then(res=>{
                            this.$message(res.data.msg);
                            this.findTask();
                        })
                        this.addTaskVisible=false;
                    } else {
                        return false;
                    }
                });

                
            },


            // 修改计划信息
            updatePatrolPlan(row){
                
                this.seeplanId=row.id;
                
                    

                 
                //  回显巡检点的数据
                //  this.axios.get("patrolplan/getpoint?id="+row.id).then(res=>{
                //     console.log(res.data.data+'1111111111111111111111111');
                //     this.arountPointId=res.data.data;
                    
                //  })
                 
                 
                //  查询出任务
                this.updatefindTask();

                this.updateSeeData.id=row.id;
                this.updateSeeData.planNo=row.planNo
                this.updateSeeData.planName=row.planName
                this.updateSeeData.patType=row.patType
                this.updateSeeData.patCycle=row.patCycle
                this.updateSeeData.startDate=row.startDate
                this.updateSeeData.endDate=row.endDate
                this.updateSeeData.remark=row.remark
                


                // 回显巡检点id
                 this.axios.get("patrolplan/getpointid?id="+this.seeplanId).then(res=>{
                    this.$refs.multipleTable.clearSelection();
                    console.log(res.data.data);
                    
                    
                    this.arountPointId=res.data.data;
                    console.log(this.updatePointData);
                    console.log(this.updatePointData[0].id);
                    console.log(this.arountPointId+'222222222222222222222222');
                console.log(this.arountPointId[0]);
                    // 选中回显的数据
                    this.reseePointt();
                 })

                this.updateVisible=true;
            },
            getRowKey(row) {
                return row.id;
            },




















            // 修改计划中的任务
            //修改查询任务
            updatefindTask(){
                 this.axios.get("patrolTask/findById?id="+this.seeplanId).then(res=>{
                    this.updateSeepatrolTaskList=res.data.data;
                 })
            },
            // 点击查看任务详情按钮
            seeTask(row){
                // 任务详情信息
                this.seeTaskData=row;
                this.axios.get("patrolTask/findByTaskId?id="+row.id).then(res=>{
                    console.log(res.data.data);
                    this.taskPointData=res.data.data;
                 })
                

                // 显示任务详情框
                this.seeTaskVisible=true;
            },
            // 修改任务
            updateTask(row){
                // 修改任务信息
                console.log(row);
                this.updateTaskData.id=row.id;
                this.updateTaskData.taskNo=row.taskNo;
                this.updateTaskData.taskName=row.taskName;
                this.updateTaskData.taskType=row.taskType;
                this.updateTaskData.taskStaru=row.taskStaru;
                this.updateTaskData.startDate=row.startDate;
                this.updateTaskData.endDate=row.endDate;
                this.updateTaskData.remark=row.remark;
                this.updateTaskData.executor=row.executor;
                this.updateTaskData.dispatcher=row.dispatcher;
                this.updateTaskData.content=row.content;

                // // 查询出任务拥有的巡检点
                // this.axios.get("patrolTask/findPointByTaskId?id="+ row.planId).then(res=>{
                //     console.log(res.data.data);
                //     this.updateTaskPonitAfter=res.data.data;
                //  })
                 // 查询出任务拥有的巡检点
                this.axios.get("patrolTask/findPointByTaskId?id="+ row.id).then(res=>{
                    console.log(res.data.data);
                    this.updateTaskPonitAfter=res.data.data;
                 })

//===========================================================================================
                this.axios.get("patrolpoint/findPlanPointByTaskId?id="+ row.id).then(res=>{
                    console.log(row.id);
                    console.log(res.data.data);
                    this.updateTaskPonit=res.data.data;
                    

                    this.updatereseePointt();
                 })
                
               
                // 显示修改任务框
                this.updateTaskVisible=true;


            },

            // 提交修改任务
            updatedTask(validaterrrr){

                this.$refs[validaterrrr].validate((valid) => {
                    if (valid) {
                        this.updateTaskData.points=this.PonitAfters;
                        this.axios.post("patrolTask/updateTask",this.updateTaskData).then(res=>{
                            this.$message(res.data.msg);
                            this.updatefindTask();
                            this.updateTaskVisible=false;
                        })
                    } else {
                        return false;
                    }
                });

                
            },

            // 删除任务
            delTask(id){
                this.$confirm('您确认删除?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
                }).then(() => {
                        this.axios.get("patrolTask/deleteTask?id="+id).then(res=>{
                        this.$message(res.data.msg);
                        this.updatefindTask();
                    })
                })

                
            },

            // 修改巡检点和巡检计划基本信息
            updatePointAndPlan(rulesupdate){
                this.$refs[rulesupdate].validate((valid) => {
                    if (valid) {
                        console.log(this.updateSeeData.pointList);
                        this.axios.post("patrolpPoint/updateTask",this.updateSeeData).then(res=>{
                            this.$message(res.data.msg);
                            this.getList();
                            this.updateVisible=false;
                        })
                    } else {
                        return false;
                    }
                });
                
            },


            // 修改框中巡检点复选框变化时调用
            updatehandleSelectionChange(val){
                let aa=[];
                let bb=[];
                console.log(val);
                for(let i of val){
                    this.axios.get("patrolpoint/pointbyid?id="+ i.id).then(res=>{
                        bb.push(res.data.data)
                    })
                    aa.push(i.id);
                }
                this.updateArountPointId=val;
                console.log(aa);
                this.updatePlanTasked=aa;
                console.log(bb);

                //this.updateSeeData.pointList=this.arountPointId;
                this.updateSeeData.pointList=bb;
            },
            // 回显巡检点
            reseePointt(){
                console.log('arountPointId.length:'+this.arountPointId.length+'===============');
                console.log('updatePointData.length:'+this.updatePointData.length+'----------------');
                // Object.entries  对象转数组
                for (let i = 0; i < this.arountPointId.length; i++) {
                    for (let j = 0; j < this.updatePointData.length; j++) {
                        if (this.arountPointId[i] == this.updatePointData[j].id) {//items里面包含有的都回显打勾
                        
                            this.$refs.multipleTable.toggleRowSelection(//回显打勾核心，toggleRowSelection的第一个参数是需要打勾的那一行数据，第二个参数表示是否选中，传true
                                this.updatePointData[j],
                                true
                            );
                        }
                    }
                }
            },
            // 修改框回显巡检点
            updatereseePointt(){
                this.$nextTick(() => {
                console.log(this.updateTaskPonit);
                console.log(this.updateTaskPonitAfter);
                // Object.entries  对象转数组
                for (let i = 0; i < this.updateTaskPonitAfter.length; i++) {
                    for (let j = 0; j < this.updateTaskPonit.length; j++) {
                        console.log(this.updateTaskPonitAfter[i] +'-----------------'+this.updateTaskPonit[j].id);
                        if (this.updateTaskPonitAfter[i] == this.updateTaskPonit[j].id) {//items里面包含有的都回显打勾
                        
                            this.$refs.multipleTable33.toggleRowSelection(//回显打勾核心，toggleRowSelection的第一个参数是需要打勾的那一行数据，第二个参数表示是否选中，传true
                                this.updateTaskPonit[j],
                                true
                            );
                        }
                    }
                }
                })
            }






            
      },

      created() {
        //   查询所有巡检点
          this.axios.get("patrolpoint/all").then(res=>{
                    console.log(res.data.data);
                    this.pointData=res.data.data;
                    this.updatePointData=res.data.data
                    
            })
            this.getExecutors();
            // 查询出所有计划类别
          this.getPatrolType();
        //   查询出所有计划周期
          this.getPatrolCycle();
        //   更新计划列表
          this.getList();
      },

  }
</script>

<style scoped>
 .el-row {
    margin-left: 30px;
  }
  .el-col {
    border-radius: 4px;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }
  .el-breadcrumb{
      height: 60px;
      line-height: 60px;
      font-size: 17px;
      margin-left: 30px;
  }
  .btn1{
      margin-left: 30px;
  }
  .tab1{
      margin-left: 30px;
  }
  .pag{
      text-align: center;
  }
  .bbb{
      height: 400px;
      width: 1450px;
  }
  .row1{
      margin-top: 30px;
      height: 50px;
  }
  .span1{
      font-size: 17px;
      font-weight: 700;
  }
</style>